﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_WA_GetAbsenceDay]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_WA_GetAbsenceDay];
GO
CREATE PROCEDURE [dbo].[sproc_WA_GetAbsenceDay] -- 得到缺勤的日期
    @staffid   int,
    @begintime datetime,
    @endtime   datetime
AS
BEGIN
SET NOCOUNT ON

declare @beginDayValue int;
declare @endDayValue int;
set @beginDayValue = dbo.fn_GetDayValue ( @begintime );
set @endDayValue = dbo.fn_GetDayValue ( @endtime );

select
    convert( nvarchar(10), [datetime], 120) as WorkDate
from
    dbo.UDS_WorkAttendence_DaySetting 
where
    (DayValue between @beginDayValue and @endDayValue)
    and NeedDuty = 1
    and DayValue not in
    (
        select DayValue
        from dbo.UDS_WorkAttendence_Data
        where StaffID = @staffid
    );

END
GO